package 集合学习.jihe_Map;

import java.util.*;

/**
 *
 *
 *
 * */

public class Map_Qitacaozuo {
    public static void main(String[] args) {

        //创建一个Map对象
        Map<Integer,Student_1> map=new HashMap<>();
        Map<Integer,Student_1> map1=new LinkedHashMap<>();
        Map<Integer,Student_1> map2=new TreeMap<>();


        //存入多个学号-学生映射
        Student_1 stu =new Student_1(10,"zhangsan",23,98.0);
        Student_1 stu1 =new Student_1(20,"lisi",24,100.0);
        Student_1 stu2 =new Student_1(30,"wangwu",20,85.0);
        Student_1 stu3 =new Student_1(10,"zhangsan",23,98.0);

        map.put(stu.getId(),stu);map1.put(stu.getId(),stu);map2.put(stu.getId(),stu);
        map.put(stu1.getId(),stu1);map1.put(stu1.getId(),stu1);map2.put(stu1.getId(),stu1);
        map.put(stu2.getId(),stu2);map1.put(stu2.getId(),stu2);map2.put(stu2.getId(),stu2);
        map.put(stu3.getId(),stu3);map1.put(stu3.getId(),stu3);map2.put(stu3.getId(),stu3);

       // map.clear();//删除所有元素
        //map.containsKey(10);是否包括键值为10
        //map.containsValue(new Student_1(10,"zhangsan",23,98.0));是否包含这个元素
        //map.replace(30,new Student_1(10,"zhangsan",23,98.0));替换对应键的内容
        System.out.println(map.size());
        System.out.println(map);
        System.out.println(map1);
        System.out.println(map2);

        System.out.println(map.get(30));

        System.out.println("---------");
        //遍历：entrySet
        Set<Map.Entry<Integer,Student_1>> entrySet=map.entrySet();
        for(Map.Entry entry:entrySet){
            System.out.println(entry.getValue());
        }

    }
}
